#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
  freopen("sub.in","r",stdin);
  freopen("sub.out","w",stdout);
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int t; cin>>t;
  while(t--){
    int a,b; cin>>a>>b;
    if(a>b)swap(a,b);
    if(a<0&&b>0)cout<<min({abs(a),abs(b),abs(a+b)})<<'\n';
    else cout<<"0\n";
  }
  return 0;
}